/*
 Copyright (c) Whitemice Consulting, 2007, 2008, 2009
 Adam Tauno Williams <awilliam@whitemice.org>
 License: MIT/X11

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/
using System;
using System.Collections.Generic;

namespace Whitemice.ZOGI
{
  public class BLOB : OwnedEntity
  {
    public BLOB() : base()
    {
    }
          
    public BLOB(IDictionary<string,object> x, int d)
      : base(x, d)
    {
    }
    
    internal override void Take(IDictionary<string,object> x, int d)
    {
      base.Take(x, d);
      Attachment = AsString(x, "attachment");
 			Creation = AsDateTime(x, "creation");
 			FileSize = AsInt32(x, "fileSize");
 			FileType = AsString(x, "fileType");
 			FileName = AsString(x, "filename");
 			SetParentObjectId(AsInt32(x, "folderObjectId"));
 			LastModified = AsDateTime(x, "lastModified");
 			ProjectId = AsInt32(x, "projectObjectId");
 			Status = AsString(x, "status");
 			Title = AsString(x, "title");
    }
    
    /* TODO
		public override bool CanRead { get { return true; } }
		public override bool CanDelete { get { return CanModify; } }
		public override bool CanModify { get { return HasHint("WRITE"); } }
		 */
		 
		public override bool FirstClass { get { return true; } }
		 
    public string Attachment { get; set; }
 		public DateTime Creation { get; set; }
 		public int FileSize { get; set; }
 		public string FileType { get; set; }
 		public string FileName { get; set; }
 			
 		public int FolderId 
 		{ 
 		  get { return ParentObjectId; }
 		  set { SetParentObjectId(value); } 
 		}
 		
 		public Folder Folder
    {
      get { return Server.Cache.Get<Whitemice.ZOGI.Folder>(FolderId); }
  	}
 			
 		public DateTime LastModified { get; set; }
 		public int ProjectId { get; set; }
 		public string Status { get; set; } 
 		public string Title { get; set; } 
  }
}
